package com.example.ujsfish.view;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.example.ujsfish.R;

public class M extends View {

    Paint mPaint1 = new Paint();
    Path path = new Path();
    Paint mPaint2 = new Paint();
    Path path2 = new Path();
    float k = 1.5f;

    public M(Context context) {
        this(context,null);
    }

    public M(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);


    }

    public M(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint1.setColor(ContextCompat.getColor(context, R.color.colorOrange));//颜色
        mPaint1.setAntiAlias(true);//抗锯齿
        mPaint1.setStyle(Paint.Style.STROKE);//设置填充方式
        mPaint1.setStrokeWidth(6);//描边宽度
        mPaint1.setTextSize(100);
        mPaint2.setColor(ContextCompat.getColor(context, R.color.teal_200));//颜色
        mPaint2.setAntiAlias(true);//抗锯齿
        mPaint2.setStyle(Paint.Style.STROKE);//设置填充方式
        mPaint2.setStrokeWidth(6);//描边宽度
        mPaint2.setTextSize(100);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);

    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        path.moveTo(1000/k,1500/k);
        path.lineTo(900/k,1450/k);
        path.lineTo(850/k,200/k);
        path.lineTo(200/k,200/k);
        path.lineTo(160/k,1400/k);
        path.lineTo(700/k,1400/k);
        path.lineTo(680/k,400/k);
        path.lineTo(430/k,400/k);
        path.lineTo(430/k,1200/k);
        canvas.drawPath(path,mPaint1);

        path2.moveTo(1000/k,1500/k);
        path2.lineTo(980/k,150/k);
        path2.lineTo(120/k,150/k);
        path2.lineTo(100/k,1500/k);
        path2.lineTo(1000/k,1500/k);

        canvas.drawPath(path2,mPaint2);
    }
}
